<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 15px;">
		<form class="layui-form" action="" style="width:100%" name="basicform">
		  <input type="hidden" id="oldId" name="oldId" value="${paramBasic.id }"/>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">编号</label>
		    <div class="layui-input-inline">
		      <input type="text" name="id" lay-verify="only" placeholder="请输入编号" class="layui-input" value="${paramBasic.id}">
		    </div>
		    <div class="layui-form-mid layui-word-aux">编号不能为空</div>
		  </div>
		  
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">大类名称</label>
		    <div class="layui-input-inline">
		      <input type="text" name="name" lay-verify="required" placeholder="请输入大类名称" class="layui-input" autocomplete="off" value="${paramBasic.name}">
		    </div>
		    <div class="layui-form-mid layui-word-aux">大类名称不能为空</div>
		  </div>

			<div class="layui-form-item">
				<label class="layui-form-label layui-form-required">内部名称</label>
				<div class="layui-input-inline">
					<input type="text" name="systemName" lay-verify="required" placeholder="请输入系统内部名称" class="layui-input" autocomplete="off" value="${paramBasic.systemName}">
				</div>
				<div class="layui-form-mid layui-word-aux">系统内部名称不能为空</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label layui-form-required">排序</label>
				<div class="layui-input-inline">
					<input type="text" name="sort" lay-verify="number"
						   placeholder="请输入排序" class="layui-input"
						   autocomplete="off" value="${paramBasic.sort}"
							maxlength="5">
				</div>
				<div class="layui-form-mid layui-word-aux">排序为数字</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-primary layui-border-blue" lay-submit="" lay-filter="sub">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary layui-border-blue">重置</button>
					<button type="button" class="layui-btn layui-btn-primary layui-border-red" onclick="closed()">关闭</button>
				</div>
			</div>
		</form>
  	</div>
	</div>
</div>
<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/common/coreInput-2.0.0.js?v=${FILE_VERSION}"></script>
<script>
//JavaScript代码区域
layui.config({
	base: getContextPath() + '/static/layuiadmin/' //静态资源所在路径
}).extend({
	index: 'lib/index' //主入口模块
}).use(['form'], function() {
	var form = layui.form;
	
	form.verify({
		only: function(value, item){ //value：表单的值、item：表单的DOM对象
		if(value == "" || value == "null"){
		      return 'id不能为空';
	    }
		if(!/^[0-9]+$/.test(value)){
	      return 'ID只能为数字';
	    }	
	    if($("#oldId").val() == null || $("#oldId").val() == "" || $("#oldId").val() != value){
	    	var dataObj = "";
	    	$.ajax({
	            url: getContextPath() + "/sys/paramBasic/add/checkId",
	            type: "post",
	            async: false,
	            data: {
	                "id" : value
	            },
	            dataType: "json",
	            success: function (json) {
	            	dataObj=json;
	            }
	        });
	    	if(dataObj.success == false){
	    		return dataObj.msg;
	    	}
	    }
	  }
	});
	
	form.on('submit(sub)', function(data){
		return saveOrUpdate($("#oldId").val(),"/sys/paramBasic",data);
	});
	
});

</script>
</body>
</html>